<?

$_table = 'sec_role';

if ($d = (int)param('delete')) {
	
	dataset('db_delete', tb('sec_perm'), "id_role=$d");
	dataset('db_delete', tb($_table), "id=$d");

	header("Location: "._transformURL($CURRENT->url, array('remove_param' => 'delete')));
	exit;
}



switch (action(array('create_object'))) {

	case 'create_object':
		
		if ($name = trim(postdata('name'))) {
			if ($id = datafetch('db_insert', tb($_table), array('name' => $name))) {
	
				// redirect to edit page
				header("Location: edit-$id/");
				exit;
			}
				// !!! else error on insert - handle it
		}
		
		break;

}
	

$DATA['objects'] = datafetch_array('db_list', array('table' => tb($_table), 'index' => 'id', 'order' => 'name'));


//debug($DATA);


?>